Ext.ns('com.hp.demo.vteam');
com.hp.demo.vteam.History = (function(){
	var historyMap = {};
	var getHashObject = function()
	{
		var href = top.location.href;
		var rlt = /^[^#]*[#](.*)\-(\d+)$/.exec(href);
		return rlt?{id:rlt[2],name:rlt[1]}:{};
	};

	var getHashName = function()
	{
		var obj = getHashObject();
		return obj.name;
	};

	var getHash = function()
	{
		var obj = getHashObject();
		return obj.name + '-' + obj.id;
	};

	var startup = function(){
		var hash = getHash();
		setInterval(function () {
			var newHash = getHash();
			if (newHash !== hash) {
				hash = newHash;
				var obj = historyMap[hash];
				com.hp.demo.vteam.base.ComponentLoader(obj.componentId,obj.msg,obj.params);
			}
		}, 50);
	};
	return {
		init:function()
		{
			startup();
		},
		
		add:function(comp,msg,params){
			if(comp !==  getHashName() || params)
			{
				var key = comp.concat('-'+Ext.id().substr(7));
				top.location.hash=key;
				historyMap[key] = {'componentId':comp,'msg':msg,params:params};
			}
		}
	};
})();
Ext.apply(com.hp.demo.vteam.History,new Ext.util.Observable());
com.hp.demo.vteam.History.init();